import java.util.ArrayList;

public class JosephusProblem {
    public static void main(String[] args) {
        int n = 12; // 总人数
        int k = 3;  // 步长
        ArrayList<Integer> people = new ArrayList<>();

        for (int i = 1; i <= n; i++) {
            people.add(i);
        }

        int index = 0;
        while (people.size() > 1) {
            index = (index + k - 1) % people.size();
            people.remove(index);
        }

        System.out.println("幸存者的编号是: " + people.get(0));
    }
}

